﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SK3000RunningTestTool.SKService;
using SK3000RunningTestTool.SKServerEnum;
using SK3000RunningTestTool.SKServerDelegate;
using SK3000RunningTestTool.SKServerSource;

namespace SK3000RunningTestTool.CustomControl
{

    public partial class ServiceTestInfoControl : UserControl, ISKServiceStruct
    {

        public event ServiceTestInfoDeleteDelegate ServiceTestInfoDeleteEvent;

        private void ServiceTestInfoDelete(object ServiceTestInfoDeleteValue)
        {
            if (ServiceTestInfoDeleteEvent != null)
            {
                ServiceTestInfoDeleteEvent(this, null);
            }
        }

        public int ID
        {
            get => ServiceTest.ID;
            set => ServiceTest.ID = value;
        }
        /// <summary>
        /// 类型ID
        /// </summary>
        public Enum_ServiceTestType TypeID
        {
            get { return ServiceTest.TypeID; }
            set { ServiceTest.TypeID = value; }
        }
        public ServiceTestInfoControl()
        {
            InitializeComponent();
        }
        private ISKServiceStruct serviceTest;

        public ISKServiceStruct ServiceTest
        {
            get { return serviceTest; }
            set
            {
                SetServiceTestType(value);
            }
        }
        public ServiceTestType Type => ServiceTest.Type;

        public string ServiceName { get => ServiceTest.ServiceName; set => ServiceTest.ServiceName=value; }


        public string ServiceRemark { get => ServiceTest.ServiceRemark; set => ServiceTest.ServiceRemark = value; }
        public string ServiceAddress { get => ServiceTest.ServiceAddress; set => ServiceTest.ServiceAddress=value; }
        public ushort ServicePort { get => ServiceTest.ServicePort; set => ServiceTest.ServicePort = value; }


        public bool SetServiceTestType(ISKServiceStruct serviceTest)
        {
            bool bolResult = false;
            this.serviceTest = serviceTest;
            if (ServiceTest != null)
            {
                txtServiceType.Text = serviceTest.Type.ServiceTestTypeName;
                txtServiceName.Text = serviceTest.ServiceName;
                txtServiceAddress.Text = serviceTest.ServiceAddress;
                txtServicePort.Text = Convert.ToString(serviceTest.ServicePort);
            }
            return bolResult;
        }

        private void btnDel_Click(object sender, EventArgs e)
        {
            ServiceTestInfoDelete(null);
        }
    }


}
